/*
-----------------------------------------------------------------------------
This source file is part of Labor3D
(Labor 3D Graphics Engine)

Copyright (c) 2011-2020 Rock Mao
* creator : Rock Mao
* created : 2011-10-15   23:29
* filename: LaborD3D112DRectRO.h
-----------------------------------------------------------------------------
*/

#ifndef __LABORD3D112DRECTRO_H__
#define __LABORD3D112DRECTRO_H__
#include "Renderer\Labor2DRectRenderableObject.h"
#include "Math\LaborMathInclude.h"
#include "Renderer\LaborIndexBuffer.h"
#include "Renderer\LaborVertexBuffer.h"

NAMESPACE_LABOR3D_BEGIN


class CLD3D112DRectRO : public IL2DRectRenderableObject
{
public:
	struct LD3D102DVertex
	{
		CLPoint4       m_pos;
		//CLColor_4f     m_color;
		CLPoint2DF     m_uv;
	};
private:
	CLColor_4f           m_Color;
	LD3D102DVertex       m_Vertex[4];
	CLPoint4             m_RectDestLB;
	CLPoint4             m_RectDestRT;
	CLRectF              m_RectSrc;
	CLTexture *          m_pTexture;
	CLIndexBuffer*       m_pIndexBuffer;
	CLVertexBuffer*      m_pVertexBuffer;
	bool                 m_bNeedUpdate;
public:
	CLD3D112DRectRO();
	virtual ~CLD3D112DRectRO();

	virtual void setDestRect( CLRectF & rect );
	virtual void setColor( CLColor_4f& _color );
	virtual void setTexture( CLTexture *pTexture, int iLayer = 0 );
	virtual void setTexture( CLTexture *pTexture, CLRectF & srcRect, int iLayer = 0 );
	virtual void draw();
	virtual void apply();
	virtual void init();
protected:
	void         _calTexUV(CLPoint2DF & uvLB, CLPoint2DF& uvRT);
	void         _calVertexData();
};

NAMESPACE_LABOR3D_END

#endif //__LABORD3D112DRECTRO_H__
